package com.video.netty.send;

import com.alibaba.fastjson.JSON;
import com.qf.entity.ResultData;
import com.video.commons.sendaop.ISocketSend;
import com.video.entity.Task;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * 音量调节，实时音乐，web发送
 * {"id":"volume", "num":"16", "taskid":"145", "terminal":["1", "2", "3"], "taskname":"xxxx"}
 * 返回
 * {"id":"volumeResponse","response":"success"}
 * {"id":"volumeResponse","response":"fail"}
 *
 * 修改任务音量
 *
 * @version 1.0
 * @user ken
 * @date 2019/6/1 14:13
 */
@Component
public class TaskVolumeSend extends ISocketSend {
    @Override
    public Map<String, Object> sendMsg(Object... objs) {

        Task task = ((ResultData<Task>) objs[0]).getData();
        int volume = (int) objs[1];

        String users = task.getUsers();
        List<String> strings = JSON.parseArray(users, String.class);

        Map<String, Object> map = new HashMap<>();
        map.put("id", "volume");
        map.put("num", volume + "");
        map.put("terminal", strings);
        map.put("taskid", task.getTaskid());
        map.put("taskname", task.getTaskname());

        return map;
    }
}
